#include "Http.hpp"
#include "Log.hpp"

void Register(const kzz::HttpRequest &req, kzz::HttpResPonse &rep)
{
    std::string text = req.Args();
    rep.SetText(text);

    rep.SetCode(200);

   // std::string suffix = req.Uri2Suffix(_targetfile);
    rep.SetHeader("Conent-Type"," text");

    int filesize = text.size();
    rep.SetHeader("Content-Length", std::to_string(filesize));
}

int main(int argc, char **argv)
{

    if (argc != 2)
    {
        // kzz::LOG(LogLevel::ERROR) << "服务器端参数传入错误";
        return 2;
    }
    uint16_t port = std::stoi(argv[1]);
    kzz::Http hp(port);
    hp.RegisterService("/register", Register);
    hp.Start();

    return 0;
}